home *** CD-ROM | disk | FTP | other *** search
/ Aminet 23 / Aminet 23 (1998)(GTI - Schatztruhe)[!][Feb 1998].iso / Aminet / dev / basic / Crazy8_src.lha / Crazy8.src / Crazy8.2.5.src next >
Text File  |  1997-11-19  |  52KB  |  1,658 lines

  1. ; Crazy 8's
  2. ; Ver 2.5
  3. ; by Curt Esser
  4. ; 113 Pauline Ave
  5. ; Crystal Lake
  6. ; Il. 60014
  7. ; camge@ix.netcom.com
  8. ; last modified  11/18/97
  9.  
  10.  
  11. WBStartup                          ;run from WorkBench!
  12. ; fade the current screen to a new palette
  13. Statement fadeto{palobj,speed} ;speed must be 1+
  14.   ;Runerrsoff                  ;goes like molasses with errors on
  15.   PaletteInfo palobj
  16.   For i = 0 To 15              ;number of available colour steps
  17.    For j=0 To 7                ;number of currently used colours
  18.     rd = Red(j)
  19.     If rd < PalRed(j)  Then rd+1   ;check each for the difference
  20.     If rd > PalRed(j) Then rd-1    ;between current colour and
  21.     bl = Blue(j)                   ;the target colour
  22.     If bl < PalBlue(j)  Then bl+1  ;and reset as needed
  23.     If bl > PalBlue(j) Then bl-1
  24.     gr = Green(j)
  25.     If gr < PalGreen(j) Then gr+1
  26.     If gr > PalGreen(j) Then gr-1
  27.     RGB j,rd,gr,bl                 ;and reset current screen
  28.    Next j
  29.    VWait speed                     ;take out if too slow or
  30.   Next i                           ;increase if too fast
  31.   ;Runerrson                   ;turn errs on if needed
  32. End Statement
  33. ntsSys=NTSC                    ;True if a NTSC system
  34. Forced.b=0                     ;if display was forced
  35.  
  36. ;Some constants for use when setting FNSPrefs
  37. #none=0
  38. #centred=%1
  39. #bold=%10
  40. #underline=%100
  41. #rightalign=%1000
  42. ;Install our font as number 1
  43. #font=1
  44. suc.l=InstallFNS(#font,?font_dat)
  45.  
  46. ;If suc.l doesn't equal #font then an error occured
  47. If suc<>#font Then Request Str$(suc),"Can't Load Font","Damn" : End
  48.  
  49.  
  50.  
  51. wb.w=WBWidth                       ;how wide is user's screen?
  52. If wb>700 Then wb=700              ;check for oversized bench
  53. wb=Int(wb/2)                       ;divide for our lo-res screen
  54. ofst.b=Int((wb - 320)/2)           ;and get horizontal to center it
  55.  
  56. .Loadup
  57. MaxLen newmod$=192                 ;for selecting new module
  58. MaxLen fi$=192                     ;filename $
  59. MaxLen pa$=192                     ;path $
  60.  
  61. BitMap 0,320,200,3                 ;lo-res 8 colors page
  62. BitMap 1,320,200,3                 ;double buffered drawing page
  63. InitPalette 0,8                    ;set a palette to black
  64. Screen 0,ofst,0,320,200,3,0," Crazy Prefs  V 2.4",0,0,0  ;open the screen
  65. Use Palette 0                      ;black screen to start
  66. Window 0,0,0,320,200,$1900," ",0,0 ;open our window
  67. ;FNSOutput 1,1                      ;set the printing output
  68. ShowBitMap 1                       ;show blank page
  69. MenusOff                           ;we use no menus
  70. CatchDosErrs                       ;show system requestors on our screen
  71. LoadBitMap 0,"data/C8.Title",0     ;load the title
  72. SetCycle 0,0,2,5,.25               ;set up for color cycling
  73. ShowBitMap 0                       ;get title screen ready
  74. Cycle 0                            ;make letters on title "squirm"
  75. fadeto{0,2}                        ;and fade in the title screen
  76. Dim txt$(74)                       ;use text from locale file C8.LOCALE
  77. Gosub GetLocale                    ;load up the locale file
  78.  
  79. Gosub loadpref                     ;get our prefs file loaded
  80.  
  81. hold.b=0
  82. Use BitMap 0
  83. LoadBitMap 1,"data/C8.playscreen.s",1  ;load game screen & palette
  84. LoadPalette 2,"data/pal.pref"          ;palette for options page
  85. LoadPalette 3,"data/pal.x"             ;all grey palette for fades
  86. LoadPalette 4,"data/pal.green"         ;other screen palettes:
  87. LoadPalette 5,"data/pal.grey"
  88. LoadPalette 6,"data/pal.tan"
  89. LoadPalette 7,"data/pal.maroon"
  90. LoadPalette 8,"data/pal.purp"
  91. LoadPalette 9,"data/pal.purp2"
  92. LoadPalette 10,"data/pal.yelo"
  93. LoadPalette pl.b,"data/pal.pointer",16 ;load colors for the pointers
  94.  
  95. Dim sd$(33)                            ;for the sounds
  96. Dim Timeout.b(33)                      ;and their length
  97. For i=0 To 33                          ;read them from data $
  98.   Read sd$(i)
  99. Next
  100. For i=0 To 33                          ;and set time to mask the
  101.   Read Timeout(i)                      ;channel for each sound
  102. Next
  103. Data$ "Laugh","aarrgghh!","awwww","blaat","clap"
  104. Data$ "drum","GameOver","scream","Shuffle","snare"
  105. Data$ "tankoo","uh-oh","spoit","tick","bell"
  106. Data$ "Cuckoo","Hey1","boom","Whoosh","BowArrow"
  107. Data$ "Cut.it.out","Girl.sigh","Glepuughn","Oooh","DaMeaning"
  108. Data$ "Spit","Yeah","Drip1","WhatDo","carumba"
  109. Data$ "doh01","doh30","doh31","excellent"
  110.  
  111. Data.b 90,31,49,76,9
  112. Data.b 9,66,54,12,26
  113. Data.b 22,34,12,3,80
  114. Data.b 35,36,48,6,60
  115. Data.b 90,34,14,50,88
  116. Data.b 26,48,40,90,90
  117. Data.b 36,28,28,90
  118. For i=0 To 33
  119.   ld$="data/s."+sd$(i)                 ;now load the sounds
  120.   LoadSound i,ld$
  121. Next
  122. Sound 0,1                              ;play the crazy laugh
  123. VWait 12                               ;and echo it in
  124. Sound 0,2                              ;the other speaker
  125.  
  126. SetErr                      ; handle any programming errors I missed
  127.  ShowBitMap 0               ;make sure we're on the right bitmap
  128.  Use BitMap 0               ;and put up a requestor
  129.  Request txt$(60),txt$(62),txt$(61)
  130.  End                        ;and end program
  131. End SetErr                  ;that wasn't so hard!
  132.  
  133. LoadShapes 0,"data/card.shapes" ;0=back 1-52 cards s/h/c/d
  134. LoadShapes 53,"data/gad.shapes" ;53=SetUp,exit,Play/54-57 cardflips
  135.                                 ;58 suit select/59 8 <-
  136.                                 ;60-63 s/h/c/d ;64 Quit Requestor
  137. LoadShapes 65,"data/pointer.shps";65-67, pointer,btn dwn pointer,wait pointer
  138. Use BitMap 1                    ;use the unseen page
  139. Boxf 16,110,40,142,6            ;draw a "blank" shape
  140. GetaShape 68,16,110,24,32       ;pick it up for erasing
  141. MidHandle 68                    ;and set its handle to center
  142. Use BitMap 0                    ;now use the title page
  143. If ModOn.b=1                    ;Load music mod if wanted
  144.    ld$=pa$+"/"+fi$              ;make loading $
  145.    LoadMedModule 0,ld$          ;load the music
  146.    music=1                      ;set the music on flag
  147. Else                            ;if no module is to be loaded
  148.    music=0                      ;make sure the flag is off!
  149. EndIf
  150. VWait 120                       ;wait for the laugh to end
  151. Gosub MusicOn                   ;start music & set filter
  152.  
  153. SetInt 5                        ;this plays the next beat of music
  154. If music=1                      ;do nothing if music is off
  155.  If hold>0                      ;if a sound is playing
  156.    hold-1                       ;only use 2 channels
  157.    If hold=1 Then SetMedMask 15 ;if the sound is done, use all 4
  158.  EndIf
  159.  PlayMed                        ;now play the next beat
  160. End If
  161. End SetInt
  162.  
  163. .Initialize
  164. Dim Deck.b(52)     ;Deck of Cards
  165. Dim Pile.b(52)     ;Discard Pile
  166. Dim Phand.b(52)    ;Player's Hand  ( Card# )
  167. Dim Ppos.w(52,1)   ;Player Card Positions (x,y)
  168. Dim Chand.b(52,1)  ;Computer's Hand
  169. complain.b=1       ;computer's complaints
  170. Split.b=0          ;end game flag
  171. Pscore.w=0         ;Player's Score
  172. Cscore.w=0         ;Computer Score
  173. Pcards.b=0         ;Cards in Player's Hand
  174. Ccards.b=0         ;Cards in Computer Hand
  175. Cspades.b=0        ;number of cards in each suit in
  176. Chearts.b=0        ;  computer's hand
  177. Cclubs.b=0
  178. Cdiamonds.b=0
  179. Cmost.b=0          ;suit computer has most of
  180. Compeight.b=0      ;how many 8's computer has
  181. mxx.b=0            ;maximum cards of any suit
  182. PlayCard.b=0       ;Card selected for play
  183. Inhand.b=0         ;Position in player's hand
  184. Suit.b=0           ;Suit of selected card
  185. Rank.b=0           ;Rank of card selected (A - K)
  186. CSuit.b=0          ;Current suit (s/h/c/d)
  187. CRank.b=0          ;Current rank of card (A - K)
  188. Dcards.b=52        ;Cards left in deck
  189. Dpile.b=0          ;Cards in discard pile
  190. card.b=0           ;Current Card
  191. sx.w=0             ;shape drawing x
  192. sy.w=0             ;shape drawing y
  193. cx.w=16            ;comp. card x
  194. cy.w=40            ;comp. card y
  195. dx.w=0             ;destination x
  196. dy.w=0             ;destination y
  197. sortflag.b=0       ;is player's hand sorted?
  198. rd.w=0             ;colors for fading
  199. bl.w=0
  200. gr.w=0
  201. flip.b=0           ;for turning cards over
  202. flipfrom.b=0
  203. flipto.b=0
  204. up.b=1
  205. down.b=-1
  206. comppull.b=0      ;number of cards computer picked up
  207. compflag.b=0      ;computer's turn
  208. playerflag.b=0    ;player's turn
  209. pickup.b=0        ;number of cards player picked up
  210. Message$=txt$(0)  ; first message
  211. see.b=0     ;bitmap being viewed
  212. draw.b=0    ;bitmap being drawn on
  213. temp.b=0    ;temporary storage
  214. temp2.b=0
  215. temp3.b=0
  216. paltemp.w=0
  217. ok.b=0      ;card ok to play
  218. shp.b=0     ;shape # to draw
  219. btn.b=0     ;1=left  2=right mouse button clicked
  220. mx.w=0      ;mouse x
  221. my.w=0      ;mouse y
  222. chx.w=0     ;check x
  223. chy.w=0     ;check y
  224. hit.b=0     ;item clicked on
  225. check.b=0   ;item being checked
  226. Row.b=1     ;Row selected card is in
  227. Rowflag.b=1 ;Number of rows in players hand
  228. setup.b=0   ;1 if game already played
  229. replay.b=0
  230. sleep.b=0   ;program is sleeping but start music if = 1 on return
  231. defpa$="data/mods"      ;default path for music module
  232. deffi$="med.moonshine"  ;default mod name
  233.  
  234. Buffer 0,8192     ;set up drawing buffers
  235. Buffer 1,8192     ;for each drawing page
  236. For i = 1 To 52   ;set up the "deck" of cards
  237.   Deck(i)=i
  238. Next
  239.   px.w=15         ;set up positions for
  240.   py.w=128        ;50 cards to go
  241. For i = 1 To 50   ;in the player's hand
  242.   If i=26         ;in two horizontal
  243.     px=15         ;rows
  244.     py=162
  245.   EndIf
  246.   Ppos(i,0)=px    ;and store them in
  247.   Ppos(i,1)=py    ;an array
  248.   px+12
  249. Next
  250. draw=1            ;draw on page one
  251. Gosub PrintRequestor
  252. .StartScreen      ;now we are ready to go
  253. ShowBitMap 0
  254. Use BitMap 0
  255. StopCycle         ;stop the title from flashing
  256. Use Palette pl.b  ;and reset the palette
  257. WPointer 65       ;show the normal game pointer
  258. ;InitPalette 0,8   ;make palette 8 black for fading
  259. For i = 0 To 7    ;set palette 0 to black again
  260.   PalRGB 0,i,0,0,0
  261. Next
  262. .StartSc2
  263. Blit 53,160,139   ;show the "SetUp Exit Play"  Requestor
  264. noise=12:Gosub makenoise   ;make sure the player is awake
  265.  
  266. Prequest          ;wait for player to select option
  267.   Gosub getmouse
  268.   If RectsHit(mx,my,1,1,38,109,44,60)  Then Goto Prefs    ;Options
  269.   If RectsHit(mx,my,1,1,238,109,44,60) Then Goto Playgame ;Play
  270.   If RectsHit(mx,my,1,1,149,124,22,30)                    ;Quit
  271.    Gosub QuitGame                        ;make sure it's not a mistake
  272.    If Split=1 Then Goto split            ;confirmed, so quit game
  273.   EndIf
  274. Goto Prequest                            ;cancelled quit, so try again
  275.  
  276. .QuitGame                    ;Confirm Quit
  277.   If setup=1                 ;We're on gamescreen
  278.      Message$=txt$(1)        ;You must be Joking!
  279.      Use BitMap draw
  280.      Gosub PrintMessage
  281.   Else
  282.      VWait 30                ;make sure player sees requestor
  283.   EndIf
  284.   Split=0                    ;default is don't quit
  285.   noise=2:Gosub makenoise
  286.   shp=64:sx=160:sy=139       ;confirm exit requestor
  287.   Use BitMap see             ;show the requestor
  288.   BBlit see,shp,sx,sy        ;on the viewed page
  289.   selection.b=0
  290.   tpl=pl
  291.   Repeat
  292.     Gosub getmouse           ;wait for the response
  293.     If mx>19 AND mx<303 AND my>117 AND my<162
  294.       If mx>19 AND mx<67
  295.         selection=1          ;CONTINUE
  296.         noise = 33
  297.       EndIf
  298.       If mx>65 AND mx<114    ;Homer
  299.         If pl=1
  300.           tpl=8   ;purple
  301.         Else
  302.           tpl=1   ;blue
  303.         EndIf
  304.         noise=30
  305.       EndIf
  306.       If mx>113 AND mx<152   ;Daffy
  307.         noise=0
  308.         If pl=7
  309.           tpl=9    ;purp2
  310.         Else
  311.           tpl=7    ;maroon
  312.         EndIf
  313.       EndIf
  314.       If mx>150 AND mx<206   ;Bugs
  315.         If pl=5
  316.           tpl=4    ;green
  317.         Else
  318.           tpl=5    ;grey
  319.         EndIf
  320.         noise=24
  321.       EndIf
  322.       If mx>205 AND mx<252   ;Bart
  323.         If pl=6
  324.           tpl=10   ;yellow
  325.         Else
  326.           tpl=6    ;tan
  327.         EndIf
  328.         noise=29
  329.       EndIf
  330.       If mx>251              ;EXIT
  331.         selection=2
  332.         noise=4
  333.       EndIf
  334.     Else
  335.       noise=3                ;bad selection
  336.     EndIf
  337.     Gosub makenoise
  338.     If tpl<>pl
  339.       fadeto{tpl,2}
  340.       pl=tpl
  341.     EndIf
  342.   Until selection >0
  343.   If selection=2
  344.     Split=1
  345.   Else
  346.     VWait 60
  347.   EndIf
  348.  
  349.   UnBuffer see               ;remove requestor from the screen
  350.   FlushBuffer see            ;and from the buffer too
  351.   Use BitMap draw            ;go back to unseen page to draw
  352.   If Split=0 AND setup=1
  353.     Message$=txt$(2)
  354.     Gosub PrintMessage
  355.   EndIf
  356.  Return
  357.  
  358. .split                         ;exit game
  359.     Message$=txt$(3)
  360.     If setup=1 Then Gosub PrintMessage
  361.     noise=6:Gosub makenoise
  362.     Gosub fademusic            ;turn music off
  363.     Free MedModule 0           ;and release the mod's memory
  364.  
  365. split2
  366.     VWait 20                   ;make sure it's done
  367.     noise=19:Gosub makenoise
  368.     fadeto{0,3}                ;fade to black
  369.     noise=17:Gosub makenoise   ;a last audio "shot"
  370.     If Forced >0               ;fix screenmode if it was forced
  371.       Gosub FixMode
  372.     EndIf
  373.     VWait 60                   ;let it finish playing
  374.     End                        ;We're history
  375.  
  376. .Playgame                    ;finally, we can play the game!
  377.   WPointer 67                ;show wait pointer
  378.   replay=0
  379.   Use BitMap draw            ;make sure we are using the unseen page
  380.   Format "###"               ;set the format for the score table
  381.   a$=txt$(4)+" " + Str$(maxpoints.w) ;the gamepoints $tring
  382.   Boxf 180,62,210,70,3               ;Erase any old text first
  383.   Boxf 108,73,176,97,3               ;and any old names
  384.   FNSOutput draw,1                   ;print on the unseen page
  385.   FNSPrint 0,113,64,a$,0,1           ;print the black shadows first
  386.   FNSPrint 0,113,63,a$,0,1
  387.   FNSPrint 0,112,64,a$,0,1
  388.   FNSPrint 0,112,63,a$,0,7           ;and now the gold text
  389.   FNSPrint 0,109,78,compname$,0,1    ;print computer's name
  390.   FNSPrint 0,109,77,compname$,0,1    ;with shadows too
  391.   FNSPrint 0,108,78,compname$,0,1
  392.   FNSPrint 0,108,77,compname$,0,7
  393.   FNSPrint 0,109,89,playername$,0,1  ;and player's name
  394.   FNSPrint 0,109,88,playername$,0,1  ;the same way
  395.   FNSPrint 0,108,89,playername$,0,1
  396.   FNSPrint 0,108,88,playername$,0,7
  397.   Blit 0,232,82                ;show the exit button
  398.   Gosub Newpage                ;switch pages
  399.   CopyBitMap see,draw          ;and make both pages look the same
  400.   fadeto{pl,1}                  ;and fade in the screen
  401. If setup=0                     ;this is the very first game
  402.   noise=12:Gosub makenoise     ;so make a noise!
  403.   VWait 30
  404. EndIf
  405.  
  406. .Newhand                       ;set up for new hand
  407.   Gosub showscore              ;update the score
  408.   If setup=1                   ;if it's not the first game
  409.     Message$=txt$(5)
  410.   EndIf
  411.   setup=1                      ;once we get here set the flag
  412.   Gosub PrintMessage           ;and print the appropriate message
  413.   Dcards=52:Pcards=0:Ccards=0:Dpile=0:compflag=0:playerflag=0
  414.   For i=1 To 52                ;set up new deck of cards
  415.    Deck(i)=i                   ;in order to start with
  416.   Next
  417.   Gosub Shuffle                ;and shuffle them
  418.   VWait 30
  419.   Gosub Shuffle                ;twice
  420.   For d=1 To 5                 ;deal 5 cards to each player
  421.     Gosub Compget              ;one to each
  422.     Gosub Playerget            ;in order
  423.   Next
  424.  
  425. Upcard                         ;turn next card up to start game
  426.   Gosub Grabcard               ;get the card
  427.   Repeat
  428.      sx-4                      ;and slide it over
  429.      Gosub Draw
  430.   Until sx=88                  ;into position
  431.   flip=up
  432.   Gosub Flipit                 ;now flip it over
  433.   Dpile+1                      ;and keep track of what's
  434.   Pile(Dpile)=card             ;in the pile
  435.   Gosub WhatCard               ;now convert it from a number
  436.   CSuit=Suit                   ;to the Current Suit
  437.   CRank=Rank                   ;and Current Rank
  438.   Gosub Sorthand                ;sort the player's hand
  439.   If music=1 Then Gosub MusicOn ;and start the music if it's on
  440.   VWait
  441.   noise=27                      ;let user know
  442.   Gosub makenoise               ;we're ready to play
  443.  
  444. ;-------------------------------------------------------------------
  445. ;                         MAIN GAME LOOP
  446. ;-------------------------------------------------------------------
  447.  
  448. .GameLoop
  449.   pickup=0            ;nothing has been picked up yet!
  450.   Message$=txt$(6)
  451.   If Ccards=1 Then Message$=txt$(7)
  452.   Gosub PrintMessage
  453.  
  454. .PlayerTurn
  455.   playerflag=1        ;human's turn
  456.   ok=0
  457.   Gosub getmouse      ;wait for input
  458.   Gosub HitWhat       ;OK, what was clicked?
  459.   CopyBitMap see,draw ;make sure both pages are the same
  460.   Select hit          ;now deal with the selection
  461.     Case 1            ;clicked deck
  462.       Gosub Playerget ;pick up a card from the deck
  463.       pickup+1        ;count how many cards are picked up this turn
  464.     Case 2            ;player clicked exit
  465.       Gosub QuitGame  ;so confirm it
  466.     Case 3            ;player clicked a card
  467.       card=PlayCard   ;ok we'll try to play it
  468.       Gosub WhatCard  ;check if it's a legal play
  469.         If ok=1       ;it is so let user play it
  470.           If card=Phand(Pcards)  ;this card was just picked up
  471.             pickup-1             ;so take it off the count
  472.           EndIf                  ;and maybe we won't need to sort hand
  473.           noise=5:Gosub makenoise
  474.           Gosub Pullcard                    ;pull it out
  475.           Gosub Playcard                    ;and play it
  476.           noise=13:Gosub makenoise
  477.           If Row<>Rowflag Then Gosub MoveUp ;if two rows move one card up
  478.           For i=Inhand To Pcards            ;this stuff moves the cards
  479.             Phand(i)=Phand(i+1)             ;over to correct the array
  480.             Next                            ;for the card we took out
  481.           Pcards-1:playerflag=0             ;and correct the count
  482.           If CRank=8 Then Gosub SetSuit     ;choose suit if an 8 played
  483.         Else                 ;go here if the card
  484.           noise=3            ;is not a legal play
  485.           Gosub makenoise    ;let the user know about it
  486.         EndIf                ;and do nothing else
  487.     Case 4                       ;clicked SORT
  488.      If Pcards=1 OR Sortflag=1   ;no need to sort
  489.       noise=16                   ;so we'll make
  490.       Gosub makenoise            ;a sound instead
  491.       VWait 10                   ;in fact, let's make
  492.       Gosub makenoise            ;it echo too!
  493.      Else
  494.       Gosub Sorthand    ;ok, we'll sort the hand
  495.      EndIf
  496.     Case 5                       ;player clicked hide
  497.        sleep=2                   ;so set the sleep flag
  498.        If music=1
  499.          sleep=1                 ;make it 1 to restart music later
  500.          music=0                 ;but turn it off now
  501.          StopMed
  502.        End If
  503.        VWait 2
  504.        If Forced>0
  505.          Gosub FixMode
  506.        EndIf
  507.        WBenchToFront_            ;and bring up WorkBench
  508.        ClickButton 0             ;and activate it
  509.        Goto PlayerTurn           ;now go wait for player to return
  510.     Default             ;player has clicked something else
  511.       noise=3           ;but there IS nothing else!
  512.       Gosub makenoise   ;let 'em know they made a mistake
  513.   End Select
  514.   VWait
  515.   If Split=1 Then Goto split  ;user wants to quit so do it
  516.   If Pcards=0                 ;player has won hand!
  517.      playerflag=1             ;so set the flag
  518.      Goto Handover            ;and end this hand
  519.   EndIf
  520.   If Dcards=0 Then Gosub Reshuffle       ;no cards left - use discards
  521.   If playerflag=1 Then Goto PlayerTurn   ;still player's turn
  522.   If Sortflag=0 AND pickup>0 Then Gosub Sorthand ;if necessary
  523.  
  524.  holdit.b=2                          ;computer's turn now
  525.  Message$=txt$(8)                    ;so greet the player
  526.  WPointer 67                         ;and put up wait pointer
  527.  comppull=0                          ;and reset pickup count
  528.  If Pcards=2 AND Ccards>2            ;player only has 2 cards
  529.    Gosub CompNoise                   ;and we have more so we complain
  530.    Select complain                   ;set a new complaint
  531.     Case 1
  532.       Message$=txt$(9)
  533.     Case 2
  534.       Message$=txt$(10)
  535.     Case 3
  536.       Message$=txt$(11)
  537.     Case 4
  538.       Message$=txt$(12)
  539.     Case 5
  540.       Message$=txt$(13)
  541.     Case 6
  542.       Message$=txt$(14)
  543.     Case 7
  544.       Message$=txt$(15)
  545.     Case 8
  546.       Message$=txt$(16)
  547.     Case 9
  548.       Message$=txt$(17)
  549.    End Select
  550.    Gosub CompComplain
  551.  EndIf
  552.  
  553.  If Pcards=1                         ;now the player only has one card
  554.    Gosub CompNoise
  555.    Select complain                   ;so REALLY whine about it
  556.     Case 1
  557.       Message$=txt$(18)
  558.       noise=20
  559.     Case 2
  560.       Message$=txt$(19)
  561.     Case 3
  562.       Message$=txt$(20)
  563.     Case 4
  564.       Message$=txt$(21)
  565.     Case 5
  566.       Message$=txt$(22)
  567.     Case 6
  568.       Message$=txt$(23)
  569.     Case 7
  570.       Message$=txt$(24)
  571.     Case 8
  572.       Message$=txt$(25)
  573.       noise=22
  574.     Case 9
  575.       Message$=txt$(26)
  576.     End Select
  577.  Gosub CompComplain
  578.  EndIf
  579. .Computerturn
  580.    Gosub PrintMessage     ;let 'em know it's our turn now
  581.    VWait hold+1           ;and make sure it's seen
  582.    ok=0:temp3=0:compflag=1:Cspades=0:Chearts=0:Cclubs=0
  583.    Cdiamonds=0            ;reset everything for this turn
  584.    For i=1 To Ccards
  585.     card=Chand(i,0)                         ;this part checks
  586.     Gosub WhatCard                          ;the computer's hand
  587.     If Suit=0 AND Rank<>8 Then Cspades+1    ;for the number of
  588.     If Suit=1 AND Rank<>8 Then Chearts+1    ;cards of each suit
  589.     If Suit=2 AND Rank<>8 Then Cclubs+1     ;so we know what suit to
  590.     If Suit=3 AND Rank<>8 Then Cdiamonds+1  ;pick if we play an 8
  591.     Chand(i,1)=0
  592.     If ok=1 Then Chand(i,1)=1     ;if the card is a legal play
  593.     If Rank=8 Then Chand(i,1)=2   ;if it is an 8
  594.    Next
  595.    Compeight=0
  596.    For i=1 To Ccards
  597.    If Chand(i,1)=1 Then temp3=i      ;ok, we will play this one
  598.    If Chand(i,1)=2 Then Compeight+1  ;how many 8's do we have?
  599.    Next
  600.     If temp3=0 AND (Chand<Compeight*2+1 OR Phand<=Compeight OR Dcards<2 OR Ccards=Compeight)
  601.      For i=1 To Ccards             ;no non-8's to play
  602.       If Chand(i,1)=2 Then temp3=i ;so play an 8 if we have one
  603.      Next                          ;unless we're way ahead
  604.     EndIf                          ;we'll save the 8 and draw
  605.    If temp3>0                      ;we're going to play a card
  606.       If comppull=0 AND Ccards=1   ;if it's our last card
  607.        noise=10:Gosub makenoise    ;let 'em know
  608.        VWait 30
  609.       EndIf
  610.     Gosub CompPlay                 ;play it!
  611.     mxx=Cspades:Cmost=0            ;this stuff
  612.     If Ccards=1                    ;finds out which suit we have
  613.      mxx=1                         ;the most of so we can pick it
  614.      If Chearts=1 Then Cmost=1     ;if we played an 8
  615.      If Cclubs=1 Then Cmost=2      ;if 2 or more are equal, we'll
  616.      If Cdiamonds=1 Then Cmost=3   ;randomly pick one of them
  617.     EndIf                          ;so as not to be predictable
  618.     If Ccards>1
  619.      If Chearts>mxx OR (Chearts=mxx AND Rnd(2)>1)
  620.        Cmost=1
  621.        mxx=Chearts
  622.      EndIf
  623.      If Cclubs>mxx OR (Cclubs=mxx AND Rnd(2)>1)
  624.        Cmost=2
  625.        mxx=Cclubs
  626.      EndIf
  627.      If Cdiamonds>mxx OR (Cdiamonds=mxx AND Rnd(2)>1) Then Cmost=3
  628.     EndIf
  629.     Gosub Playcard                ;alright, play it already!
  630.     If Rank=8 Then Gosub SetSuit  ;ok an 8! Set our suit!
  631.     If Ccards=1                   ;we only have one card
  632.       noise=11                    ;left so warn the player
  633.       Gosub makenoise
  634.     End If
  635.    EndIf
  636.  
  637.   If temp3=0                      ;we're picking up too
  638.      If comppull>1                ;many un-playable cards
  639.       Gosub CompNoise
  640.       Select complain             ;so moan about it!
  641.        Case 1
  642.         Message$=txt$(27)
  643.        Case 2
  644.         Message$=txt$(28)
  645.        Case 3
  646.         Message$=txt$(29)
  647.        Case 4
  648.         Message$=txt$(30)
  649.        Case 5
  650.         Message$=txt$(31)
  651.        Case 6
  652.         Message$=txt$(32)
  653.        Case 7
  654.         Message$=txt$(33)
  655.        Case 8
  656.         Message$=txt$(34)
  657.        Case 9
  658.         Message$=txt$(35)
  659.       End Select
  660.       Gosub CompComplain
  661.       Gosub PrintMessage
  662.      EndIf
  663.      VWait hold+15
  664.      Gosub Compget                 ;go get another card
  665.      comppull+1
  666.     EndIf
  667.   If Dcards=0                      ;and re-shuffle the discards
  668.      Gosub Reshuffle               ;if the deck is all used up
  669.      VWait 30
  670.      EndIf
  671.   If ok=0 AND Dcards>0  Then Goto Computerturn ;still our turn
  672.   If Ccards=0 Then Goto Handover  ;we won this hand
  673.   compflag=0                      ;we didn't win
  674.   Goto GameLoop                   ;so back to the player
  675.  
  676. .Handover                        ;ok, we managed to finish a hand
  677.   WPointer 67                    ;put up the busy pointer
  678.   Gosub fademusic                ;and can the music
  679.   If playerflag=0                ;computer won
  680.      noise=2                     ;make appropriate noise
  681.      Gosub makenoise
  682.      Message$=txt$(36)           ;and print a message
  683.      Gosub PrintMessage
  684.      VWait 65
  685.      Repeat
  686.        Inhand=Pcards:card=Phand(Inhand)  ;now get the player's cards
  687.        Gosub Pullcard                    ;one at a time
  688.        Gosub Playcard                    ;& put 'em on discard pile
  689.        Gosub Score                       ;and score them
  690.        Pcards-1
  691.      Until Pcards=0                      ;till we got 'em all
  692.  EndIf
  693.  
  694.  If compflag=0                                ;player won
  695.      Message$=txt$(37)  ;say it in print
  696.      noise=0                                  ;and make a noise
  697.      Gosub makenoise                          ;now print the message
  698.      Gosub PrintMessage                       ;pause for a bit
  699.      VWait 100
  700.      Repeat               ;now throw computer's cards
  701.       temp3=Ccards        ;on the discard pile
  702.       Gosub CompPlay      ;one at a time
  703.       Gosub Playcard
  704.       Gosub Score         ;and score each
  705.      Until Ccards=0       ;till they're all gone
  706. EndIf
  707. VWait 50
  708. flip=down
  709. Gosub Flipit       ;turn the deck face down
  710. VWait 20
  711. For i=1 To 2       ;now erase the deck
  712.  Use BitMap draw   ;on both screens
  713.  Blit 68,sx,sy     ;by drawing a blank card
  714.  shp=0             ;but buffer-blit
  715.  Gosub Draw        ;the card-back pic on both pages
  716. Next
  717.  noise=18
  718.  Gosub makenoise
  719.  Repeat            ;now slide the discard pile back onto
  720.  sx+4              ;the main deck 4 pixels at a time
  721.  Gosub Draw
  722.  Until sx=232
  723. Gosub Drawdone     ;reset everything for the next time
  724. If Cscore=>maxpoints OR Pscore=>maxpoints  ;if the game is over do this stuff
  725.   noise=6
  726.   Gosub makenoise
  727.   If (Cscore=>maxpoints AND scoreon.b =0) OR (scoreon=1 AND Pscore =>maxpoints)
  728.     Message$=txt$(38)       ;player won the game message
  729.   Else
  730.     Message$=txt$(39)       ;computer won so print this one
  731.   EndIf
  732.   Gosub PrintMessage
  733.   Cscore=0                   ;reset scores
  734.   Pscore=0
  735.   VWait 120                  ;and pause a little
  736.   see=0
  737.   draw=1
  738.   ShowBitMap 0
  739.   Use BitMap 0
  740.   Blit 68,301,82             ;erase exit button
  741.   Blit 68,266,82             ;on both screens
  742.   replay=1                   ;set the replay flag
  743.   Goto StartSc2              ;and go back to the beginning
  744. EndIf
  745. Goto Newhand   ;game not over, play another hand
  746.  
  747. .Draw              ;double buffer drawing routine
  748.      ShowBitMap see        ;show the already-drawn page
  749.      VWait                 ;wait for the Vblank
  750.      Use BitMap draw       ;draw on the unseen page
  751.      UnBuffer draw         ;erase the stuff we drew last time
  752.      BBlit draw,shp,sx,sy  ;buffer-blit specified shape
  753.      Exchange see,draw     ;make this the new viewing page
  754.      Return
  755.  
  756. Drawdone                   ;this part simply
  757.      ShowBitMap see        ;resets both drawing pages
  758.      VWait                 ;so they are the same
  759.      CopyBitMap see,draw   ;and clears out both buffers
  760.      FlushBuffer 0         ;so we are ready for the next
  761.      FlushBuffer 1         ;animation
  762.      Use BitMap draw
  763.      Return
  764.  
  765. Newpage                    ;this routine switches the
  766.      Exchange see,draw     ;drawing (unseen) and
  767.      ShowBitMap see        ;the veiwing (seen) pages
  768.      VWait                 ;so we don't have to do it
  769.      Use BitMap draw       ;by hand all the time
  770. Return
  771.  
  772. .Flipit       ;this makes card flipping animation
  773.      flipfrom=54:flipto=57    ;flip shapes from face down to face up
  774.      If flip=down Exchange flipfrom,flipto  ;do in reverse if needed
  775.      For i=flipfrom To flipto Step flip     ;draw the shapes one
  776.        shp=i                                ;per frame till they
  777.        Gosub Draw                           ;are all done
  778.      VWait
  779.      Next
  780.      shp=card                             ;then draw actual card
  781.      If flip=down Then shp=0              ;or card back
  782.      Gosub Draw
  783.      noise=13
  784.      Gosub makenoise
  785.      Gosub Drawdone
  786.      Return
  787.  
  788. .Reshuffle                  ; reshuffles the discard pile
  789.    If Dpile=1 Then Return   ; there's only one card - forget it!
  790.    For i=1 To Dpile-1       ; leave the top card out
  791.    Deck(i)=Pile(i)          ; and set up our new deck using
  792.    Next                     ; the rest of the discards
  793.    sx=88:sy=82              ; now slide top card over
  794.    shp=Pile(Dpile)
  795.    Use BitMap draw
  796.    For i=1 To 2
  797.     Blit Pile(Dpile-1),sx,sy  ;first we have to draw
  798.     BBlit draw,shp,sx,sy      ;the next card down in the pile
  799.    Gosub Newpage              ;on both pages under top card
  800.    Next                       ;because it will be seen soon
  801.    For i=1 To 12              ;now we slide the top card
  802.    sx-2                       ;over to the left
  803.    Gosub Draw
  804.    Next
  805.    Gosub Drawdone
  806.    sx=88:sy=82:flip=down:Gosub Flipit ;now flip the "deck" down
  807.    For i=1 To 2                       ;now we need to erase
  808.    Blit 68,sx,sy                      ;both pages under the
  809.    BBlit draw,shp,sx,sy               ;"deck" pic
  810.    Gosub Newpage                      ;actually just 1 card back pic
  811.    Next
  812.    Repeat                      ;now we slide this over to the right
  813.      sx+6
  814.      Gosub Draw
  815.    Until sx=232                ;until it gets to the deck position
  816.    Gosub Drawdone
  817.    sx=64
  818.    shp=Pile(Dpile)             ;now slide the top card back
  819.    Blit 68,sx,sy               ;where it was
  820.    For i=1 To 2
  821.     Blit 68,sx,sy
  822.     BBlit draw,shp,sx,sy
  823.     Gosub Newpage
  824.    Next
  825.    For i=1 To 12
  826.    sx+2
  827.    Gosub Draw
  828.    Next
  829.    Gosub Drawdone
  830.    If CRank=8                  ;and if it's an 8
  831.       Use BitMap see           ;don't forget to draw the
  832.       Blit 60+CSuit,sx,sy      ;selected suit back on it!
  833.       Use BitMap draw
  834.       Blit 60+CSuit,sx,sy
  835.     EndIf
  836.    Dcards=Dpile-1              ;now reset
  837.    Pile(1)=Pile(Dpile)         ;the discard pile
  838.    Dpile=1
  839.  
  840. .Shuffle                       ;shuffle the deck
  841.  If Dcards=1 Then Return       ;only one card - forget it!
  842.  WPointer 67                   ;busy pointer
  843.  Blit 0,230,82                 ;draw two card backs
  844.  Blit 0,234,82                 ;offset from normal position
  845.                                ;but only on one page for animation
  846.   For q=1 To 4                 ;shuffle them 4 times
  847.    For i=1 To Dcards                     ;re-arrainge deck
  848.    Exchange Deck(i),Deck(Rnd(Dcards)+1)  ;at random by exchanging
  849.    Next                                  ;card numbers
  850.    noise=8               ;now make shuffling
  851.    Gosub makenoise       ;sound and
  852.    For i=1 To 20         ;animate by fliping the pages
  853.      ShowBitMap draw     ;back and forth enough times
  854.      VWait               ;to cover the length of the sound
  855.      ShowBitMap see
  856.      VWait               ;the actual shuffling takes no time at all
  857.    Next                  ;this is all for show!
  858.   Next
  859.    Gosub Drawdone
  860.    Return
  861.  
  862. Grabcard         ;pick up the top card on the deck
  863.    If Dcards<1   ;wait a minute! There's no more cards here!
  864.      card=-1     ;so set the flag
  865.      Return      ;and leave
  866.    EndIf
  867.    card=Deck(Dcards)      ;always take the top card
  868.     Dcards-1              ;and subtract one from the deck count
  869.     sx=232                ;set the starting position
  870.     sy=82                 ;for the animation
  871.     shp=0                 ;and set to card-back shape
  872.     If Dcards=0           ;and if this is the last card
  873.      Use BitMap draw      ;erase the deck pic
  874.      For i=1 To 2         ;on both screens
  875.       Blit 68,sx,sy
  876.       BBlit draw,0,sx,sy  ;but buffer-blit the one card back
  877.       Gosub Newpage
  878.      Next
  879.     EndIf
  880.   noise=18                ;ok, make a sound
  881.   Gosub makenoise
  882.   Return
  883.  
  884. .Compget                     ;pick up a card
  885.    Gosub Grabcard            ;and send it to the computer's hand
  886.     Repeat
  887.       If sx>cx+4 Then sx-4   ;this stuff moves the
  888.       If sx>cx Then sx-1     ;card toward the next spot in
  889.       If sx<cx Then sx+2     ;the computer's hand and slows
  890.       If sy>cy Then sy-1     ;down when it gets close so we
  891.       shp=0                  ;can hit the exact spot
  892.       Gosub Draw
  893.     Until sx=cx AND sy=cy
  894.    noise=13
  895.    Gosub makenoise           ;make a sound when it gets there
  896.    Ccards+1                  ;update the amount of cards
  897.    Chand(Ccards,0)=card      ;and the computer array
  898.    cx+6                      ;reset position for next card
  899.    Gosub Drawdone
  900.  Return
  901.  
  902. .Playerget                   ;player picks up a card
  903.    Gosub Grabcard            ;get next card from deck
  904.    If card=-1 Then Return    ;wait a minute-all cards GONE!
  905.     Pcards+1                 ;add one to our count
  906.     Sortflag=0               ;and re-set the sort flag
  907.     Repeat
  908.       If sx>Ppos(Pcards,0)+4 Then sx-4    ;this slides the card
  909.       If sx>Ppos(Pcards,0) Then sx-1      ;into the player's hand
  910.       If sx<Ppos(Pcards,0)-4 Then sx+4    ;just like computer above
  911.       If sx<Ppos(Pcards,0) Then sx+1
  912.       If sy<Ppos(Pcards,1) Then sy+2
  913.       Gosub Draw
  914.     Until sx=Ppos(Pcards,0) AND sy=Ppos(Pcards,1)
  915.    Phand (Pcards)=card       ;and update player's array
  916.    flip=up                   ;but we have to flip the player's
  917.    Gosub Flipit              ;cards face up so we can see it
  918.  
  919.  Return
  920.  
  921. .PrintMessage                ;this prints message in message box
  922.                              ;on the draw page
  923.  FNSOutput draw,1
  924.  Boxf 4,185,314,196,3
  925.  FNSPrint 1,160,186,Message$,#centred,1
  926.  FNSPrint 1,160,185,Message$,#centred,1
  927.  FNSPrint 1,159,186,Message$,#centred,1
  928.  FNSPrint 1,159,185,Message$,#centred,7
  929.  
  930. ; copy text from draw to see, 1 line at a time
  931.  
  932.  For i = 184 To 197
  933.   addvaldraw.w=ADDValue(draw,0,i)
  934.   addvalsee.w=ADDValue(see,0,i)
  935.   Derez draw,see,addvaldraw,addvalsee,1,1
  936.   VWait
  937.  Next
  938.  Return
  939.  
  940. .getmouse       ;wait for a mouseclick or keypress
  941.   WPointer 65   ;regular pointer
  942.   FlushEvents   ;clear any prior events (for the trigger-happy user)
  943.   ev.l=WaitEvent           ;multi-task until response detected
  944.   If sleep >0              ;program was sleeping (screen hidden)
  945.      If sleep = 1          ;turn music on
  946.         If Forced=2        ;force screenmode if it was done before
  947.           ForcePAL
  948.         EndIf
  949.         If Forced=1
  950.           ForceNTSC
  951.         EndIf
  952.         music=1            ;fix the music flag
  953.         Gosub MusicOn      ;and re-start it
  954.      EndIf
  955.      sleep=0               ;re-set the sleep flag
  956.   EndIf
  957.   If ev=$400                     ;key was pressed
  958.    t$=Inkey$
  959.    If t$="p"
  960.      noise =4
  961.      Gosub makenoise
  962.      VWait
  963.      ForcePAL
  964.      Forced=2
  965.    EndIf
  966.    If t$="n"
  967.      noise=4
  968.      Gosub makenoise
  969.      VWait
  970.      ForceNTSC
  971.      Forced=1
  972.    EndIf
  973.    If t$="m" OR t$="M"   ;user wants to toggle music off/on
  974.      If ModOn=1                  ;we have loaded a mod
  975.        If music=1                ;so do it
  976.          Gosub fademusic         ;but if off, do it gracefully
  977.          music=0
  978.        Else
  979.          music=1                 ;was off, turn it on
  980.          Gosub MusicOn           ;put a coin in the jukebox
  981.        End If
  982.      Else                        ;NO MOD IN MEMORY!!!
  983.        ShowBitMap 0
  984.        Request txt$(60),txt$(63),txt$(64)
  985.        ShowBitMap see
  986.      EndIf
  987.    End If
  988.    Goto getmouse                 ;go back & wait for mousebutton
  989.   End If
  990.  
  991.  btn=1                    ;left button down
  992.  If Joyb(0)=2 Then btn=2  ;right button
  993.  WPointer 66              ;show button down pointer
  994.  Repeat                   ;now wait
  995.  Until Joyb(0)=0          ;till it is released
  996.  WPointer 65              ;use regular pointer
  997.  mx=WMouseX               ;and get the
  998.  my=WMouseY               ;pointer's position
  999.  FlushEvents              ;again, save the trigger-happy
  1000. Return                    ;and continue the program
  1001.  
  1002. HitWhat             ;this determines what was clicked
  1003.   hit=0             ;first we reset the flags
  1004.   PlayCard=0
  1005.   If RectsHit (mx,my,1,1,221,67,22,30) Then hit=1 ; draw a card
  1006.   If RectsHit (mx,my,1,1,289,67,22,30) Then hit=2 ; exit button
  1007.   If RectsHit (mx,my,1,1,254,67,22,30) Then hit=4 ; sort button
  1008.   If RectsHit (mx,my,1,1,290,9,27,9)   Then hit=5 ; hide bitton
  1009.   If hit>0 Then Return  ;Got it! we don't need to check for cards
  1010.   check=1
  1011.   If Pcards=1 Then Goto fullcheck ;only one card left!
  1012.   checkcards   ;checks all the visible card positions from left
  1013.   If RectsHit (mx,my,1,1,Ppos(check,0)-11,Ppos(check,1)-15,11,30)
  1014.     hit=3
  1015.     PlayCard=Phand(check)
  1016.     Inhand=check
  1017.   EndIf
  1018.   check+1
  1019.   If PlayCard=0 AND check <Pcards Then Goto checkcards ;nope, try next
  1020.  
  1021.   fullcheck ;the last card on right is bigger so we check full area
  1022.   If RectsHit (mx,my,1,1,Ppos(check,0)-11,Ppos(check,1)-15,22,30)
  1023.     hit=3
  1024.     PlayCard=Phand(check)
  1025.     Inhand=check
  1026.   EndIf
  1027. Return
  1028.  
  1029. .WhatCard      ;determine the suit & rank of a card from its number
  1030.   Suit=0       ;set to first suit
  1031.   Rank=card    ;this is the card's number
  1032.  
  1033. checksuit
  1034.   If Rank>13        ;only 13 cards per suit
  1035.     Suit+1          ;so go to next suit
  1036.     Rank-13         ;and subtract 13
  1037.     Goto checksuit  ;and try again
  1038.   EndIf
  1039.   ok=0                                              ;now reset flag
  1040.   If Suit=CSuit OR Rank=CRank OR Rank=8 Then ok=1   ;and check for
  1041. Return                                              ;playability
  1042.  
  1043. .Pullcard           ;pull a card out of the player's hand
  1044.   sx=Ppos(Inhand,0)            ;get the drawing positions from
  1045.   sy=Ppos(Inhand,1)            ;the player position array
  1046.   shp=card                     ;and set the drawing shape
  1047.   Row=1:Rowflag=1:temp2=Pcards ;reset the flags to 1 row of cards
  1048.   If Inhand>25 Then Row=2      ;card selected from second row
  1049.   If Pcards>25 Then Rowflag=2  ;player has TWO rows of cards
  1050.   If Row=1 AND Rowflag=2 Then temp2=25  ;but he selected from top row
  1051.   For q=1 To 2                 ;set up both pages
  1052.     Blit 68,sx,sy              ;draw blank shape to erase
  1053.     If Inhand>1 AND Inhand<>26 Then Blit Phand(Inhand-1),Ppos(Inhand-1,0),Ppos(Inhand-1,1)
  1054.     BBlit draw,shp,sx,sy       ;and buffer blit the card
  1055.      If Inhand<>Pcards AND Inhand <>25   ;if not last card in row
  1056.       For j= Inhand+1 To temp2           ;re draw other cards to
  1057.         Blit Phand(j),Ppos(j,0),Ppos(j,1);the right of selected one
  1058.       Next
  1059.      EndIf
  1060.    Gosub Newpage              ;and switch pages
  1061.   Next q                      ;do the other page
  1062.    If Inhand=Pcards OR Inhand=25 Then Goto ready ;if last card
  1063.    For i=0 To 12 Step 2       ;otherwise, move cards to right
  1064.      sy-5                     ;over to fill the space
  1065.      Gosub MoveEm
  1066.    Next i
  1067.    i=12
  1068.    Gosub MoveEm
  1069.  
  1070. ready                  ;ok all done
  1071.   ShowBitMap see
  1072.   VWait
  1073.   Use BitMap draw
  1074.   Return
  1075.  
  1076. MoveEm
  1077.      UnBuffer draw
  1078.      BBlit draw,shp,sx,sy
  1079.      Blit 68,Ppos(temp2,0),Ppos(temp2,1)
  1080.      For j= Inhand+1 To temp2
  1081.        Blit Phand(j),Ppos(j,0)-i,Ppos(j,1)
  1082.      Next j
  1083.      Gosub Newpage
  1084. Return
  1085.  
  1086. MoveUp
  1087.  temp3=Inhand
  1088.  Inhand=26
  1089.  card=Phand(26)
  1090.  Gosub Pullcard
  1091.  Repeat
  1092.   If sx<Ppos(25,0) Then sx+2
  1093.   If sx<Ppos(25,0)-6 Then sx+4
  1094.   If sx>200 AND  sy<128 Then sy+1
  1095.   If sy>128 Then sy-1
  1096.   Gosub Draw
  1097.  Until sy=128 AND sx=Ppos(25,0)
  1098.  Gosub Drawdone
  1099.  Inhand=temp3
  1100. Return
  1101.  
  1102.  
  1103.  
  1104. .CompPlay
  1105.     cx-6:sx=cx:sy=cy:card=Chand(temp3,0)
  1106.     For i=1 To 2
  1107.       Blit 68,sx,sy
  1108.       If Ccards>1 Then Blit 0,sx-6,sy
  1109.       BBlit draw,0,sx,sy
  1110.       Gosub Newpage
  1111.     Next
  1112.     flip=up
  1113.     Gosub Flipit
  1114.     For i=temp3 To Ccards
  1115.       Chand(i,0)=Chand(i+1,0)
  1116.      Next
  1117.     For i=1 To 2
  1118.       Blit 68,sx,sy
  1119.       If Ccards>1 Then Blit 0,sx-6,sy
  1120.       BBlit draw,card,sx,sy
  1121.       Gosub Newpage
  1122.      Next
  1123.     Ccards-1
  1124. Return
  1125.  
  1126. .SetSuit
  1127.  If Pcards=0 OR Ccards=0 Then Return
  1128.  If compflag=0 AND Sortflag=0 AND pickup>0 Then Gosub Sorthand
  1129.  Message$=txt$(40)  ;"O.K.  Choose Your Suit"
  1130.  If compflag=1 Then Message$=txt$(41)  ;"Hmmmmm.  Let's see!"
  1131.  Gosub PrintMessage
  1132.  noise=23:Gosub makenoise
  1133.  ShowBitMap draw
  1134.  VWait
  1135.  Use BitMap draw
  1136.  Blit 59,88,82
  1137.  Blit 58,40,82
  1138.  If compflag=1
  1139.   Suit=Cmost
  1140.   Message$=txt$(41)
  1141.   VWait 150
  1142.   Goto useit
  1143.  EndIf
  1144. playerpick
  1145.  Gosub getmouse
  1146.  Suit=5
  1147.  temp=8
  1148.  For i=0 To 3
  1149.   If RectsHit(mx,my,1,1,temp,71,14,15) Then Suit=i
  1150.   temp+15
  1151.   Next
  1152.  If Suit=5
  1153.   noise=3
  1154.   Gosub makenoise
  1155.   Goto playerpick
  1156.  EndIf
  1157.  Message$=txt$(43)
  1158. useit
  1159. Use BitMap see
  1160. Blit 60+Suit,88,82
  1161. CSuit=Suit
  1162. Gosub Drawdone
  1163. noise=5
  1164. Gosub makenoise
  1165. Gosub PrintMessage
  1166. ;VWait 30
  1167. If compflag=1
  1168.    noise=21
  1169. Else
  1170.    noise=26
  1171.    If Pcards<3 Then noise=33
  1172. EndIf
  1173. Gosub makenoise
  1174. VWait 100
  1175. Return
  1176.  
  1177. .Sorthand
  1178.  Rowflag=1
  1179.  If Pcards>25 Then Rowflag=2
  1180.  card=Phand(Pcards)
  1181.  sx=Ppos(Pcards,0)
  1182.  sy=Ppos(Pcards,1)
  1183.  dx=Ppos(1,0)
  1184.  Gosub Slideleft
  1185.  If Rowflag=2
  1186.    sx=Ppos(25,0)
  1187.    sy=Ppos(25,1)
  1188.    card=Phand(25)
  1189.    Gosub Slideleft
  1190.  EndIf
  1191. For i= Pcards+1 To 52
  1192.   Phand(i)=60
  1193. Next
  1194. Sort Phand()
  1195. card=Phand(Pcards)
  1196. sx=Ppos(1,0)
  1197. sy=Ppos(Pcards,1)
  1198. temp=1
  1199. temp2=Pcards
  1200. If Rowflag=2 Then temp=26
  1201. Gosub Slideright
  1202.  If Rowflag=2
  1203.    Rowflag=1
  1204.    sx=Ppos(1,0)
  1205.    sy=Ppos(1,1)
  1206.    card=Phand(25)
  1207.    temp=1
  1208.    temp2=25
  1209.    Gosub Slideright
  1210.  EndIf
  1211. Sortflag=1
  1212. Return
  1213.  
  1214. Slideright
  1215.  flip=up
  1216.  Gosub Flipit
  1217.  noise=18:Gosub makenoise
  1218.  dx=Ppos(temp2,0)
  1219.  If sx<>dx
  1220.   Repeat
  1221.    sx+4
  1222.     For i=temp To temp2
  1223.      If sx>Ppos(i,0) AND sx<Ppos(i,0)+20 Then Blit Phand(i),Ppos(i,0),Ppos(i,1)
  1224.     Next
  1225.    Blit card,sx,sy
  1226.    Gosub Newpage
  1227.   Until sx=dx
  1228.  EndIf
  1229.  Gosub Drawdone
  1230. Return
  1231.  
  1232. Slideleft
  1233.  noise=18:Gosub makenoise
  1234.  If sx<>dx
  1235.   Repeat
  1236.    Blit 68,sx+3,sy
  1237.    sx-3
  1238.    Blit card,sx,sy
  1239.    Gosub Newpage
  1240.   Until sx=dx
  1241.  EndIf
  1242.  Gosub Drawdone
  1243.  flip=down
  1244.  Gosub Flipit
  1245. Return
  1246.  
  1247. .Score
  1248.  VWait 15
  1249.  card=shp
  1250.  Gosub WhatCard
  1251.  If Rank>10 Then Rank=10
  1252.  If Rank=1
  1253.     Rank=20
  1254.     noise=1+15*playerflag
  1255.     Gosub makenoise
  1256.   EndIf
  1257.  If Rank=8
  1258.     Rank=50
  1259.     noise=7+3*playerflag
  1260.     Gosub makenoise
  1261.   EndIf
  1262.  noise=14+playerflag
  1263.  Gosub makenoise
  1264.   If (playerflag=0 AND scoreon=0) OR (playerflag=1 AND scoreon=1)
  1265.    Pscore=Pscore+Rank
  1266.   Else
  1267.    Cscore=Cscore+Rank
  1268.   EndIf
  1269.  
  1270. showscore            ;update the score box
  1271.  Format "000"        ;with three number format
  1272.  BitMapOutput see    ;just use the seen page
  1273.  Colour 7,1          ;gold on black
  1274.  Locate 23,9.9
  1275.  Print Str$(Cscore)  ;Computer's score
  1276.  Locate 23,11
  1277.  Print Str$(Pscore)  ;Player's score
  1278.  Gosub Drawdone
  1279.  VWait 35
  1280.  Return
  1281.  
  1282. .Playcard
  1283.  Repeat
  1284.   If sx<84 Then sx+4
  1285.   If sx<88 Then sx+1
  1286.   If sx>92 Then sx-4
  1287.   If sx>88 Then sx-1
  1288.   If sy>85 Then sy-3
  1289.   If sy>82 Then sy-1
  1290.   If sy<80 Then sy+2
  1291.   If sy<82 Then sy+1
  1292.   Gosub Draw
  1293.   Until sx=88 AND sy=82
  1294.   Gosub Drawdone
  1295.   Dpile+1
  1296.   Pile(Dpile)=card
  1297.   Gosub WhatCard
  1298.   CSuit=Suit
  1299.   CRank=Rank
  1300. Return
  1301.  
  1302. .Prefs              ;Options screen w/GT gadgets
  1303. t$=txt$(48)+"|"+txt$(49)
  1304. #ModString   = 51
  1305. #BtnSave     = 52
  1306. #ModReq      = 54
  1307. #Music       = 55
  1308. #SndFilter   = 56
  1309. #LoseWinMX   = 58
  1310. #ScoreMX     = 59
  1311. #BtnUse      = 60
  1312. #Pname       = 61
  1313. #Cname       = 62
  1314. GTString    0,#ModString,70,53,200,16,txt$(44),#PLACETEXT_LEFT,200,ld$
  1315. GTButton    0,#BtnSave,8,169,81,16,txt$(45),#PLACETEXT_IN
  1316. GTButton    0,#ModReq,270,53,19,16,"?",#PLACETEXT_IN
  1317. GTCheckBox  0,#Music,26,79,26,11,txt$(46),#PLACETEXT_RIGHT
  1318. GTCheckBox  0,#SndFilter,202,79,26,11,txt$(47),#PLACETEXT_RIGHT
  1319. GTMX        0,#LoseWinMX,46,116,17,9,"",#PLACETEXT_RIGHT,t$,scoreon.b
  1320. GTMX        0,#ScoreMX,208,113,17,9,"",#PLACETEXT_RIGHT," 50|100|150|200|300",scbtn.b
  1321. GTButton    0,#BtnUse,228,169,81,16,txt$(50),#PLACETEXT_IN
  1322. GTString    0,#Pname,64,16,85,16,txt$(51),#PLACETEXT_LEFT,8,playername$
  1323. GTString    0,#Cname,214,16,85,16,"Amiga",#PLACETEXT_LEFT,8,compname$
  1324.  
  1325. *gtscr.Screen = Peek.l (Addr Screen(0))
  1326. offy.b = *gtscr\WBorTop + *gtscr\_RastPort\TxHeight +1
  1327. fadeto{3,1}
  1328. Window 1,0,0,320,200,$1100,"Crazy Prefs  --  version 2.5",1,2
  1329. WPointer 65
  1330. noise=28:Gosub makenoise
  1331. offx.b = WLeftOff
  1332. AttachGTList 0,1
  1333. fadeto{2,1}
  1334. If ModOn.b=1 Then GTSetAttrs  0,#Music, #GTCB_Checked, True
  1335. If Fltr.b=True Then GTSetAttrs  0,#SndFilter, #GTCB_Checked, True
  1336. GTBevelBox 0,7+offx,1+offy,302,35,1
  1337. GTBevelBox 0,7+offx,39+offy,302,56,1
  1338. GTBevelBox 0,7+offx,98+offy,302,66,1
  1339. WJam 0
  1340. WColour 1,0
  1341. WLocate 28,104 : Print txt$(52)
  1342. WLocate 198,102 : Print txt$(53)
  1343. WColour 2,0
  1344. WLocate 138,43 : Print txt$(54)
  1345. WLocate 115,6 : Print txt$(55)
  1346.  
  1347. ; --- Kick 2.00 compatible GTGetInteger and GTGetString commands
  1348. ; ---
  1349. ; --- GTGetStr GTList#, gadid   (GTGetString replacement)
  1350. ; ---
  1351. Function.s GTGetStr{lst.w, gdt.w}
  1352.   *gad.Gadget = GTGadPtr(lst, gdt)
  1353.   *si.StringInfo = *gad\SpecialInfo
  1354.   a$= Peek$(*si\_Buffer)
  1355.   Function Return a$
  1356. End Function
  1357. split=0
  1358. .prefloop
  1359.   ev.l = WaitEvent
  1360.  
  1361.   If ev = #IDCMP_GADGETUP OR ev= #IDCMP_GADGETDOWN
  1362.     noise=13:Gosub makenoise
  1363.     If ev=$20
  1364.       Select GadgetHit
  1365.         Case #ScoreMX
  1366.           scbtn=EventCode
  1367.           If scbtn =0 Then maxpoints=50
  1368.           If scbtn =1 Then maxpoints=100
  1369.           If scbtn=2 Then maxpoints=150
  1370.           If scbtn=3 Then maxpoints=200
  1371.           If scbtn=4 Then maxpoints=300
  1372.         Case #LoseWinMX
  1373.           scoreon=EventCode
  1374.       End Select
  1375.     Else
  1376.       Select GadgetHit
  1377.         Case #ModString
  1378.           newmod$=GTGetStr{0,51}
  1379.           Gosub CheckMed
  1380.         Case #BtnSave
  1381.           compname$=GTGetStr{0,62}
  1382.           playername$=GTGetStr{0,61}
  1383.           Gosub savepref
  1384.           split=1
  1385.         Case #ModReq
  1386.           ld$=defmed$
  1387.           newmod$=ASLFileRequest$(txt$(56),pa$,fi$,0,0,320,200)
  1388.           Gosub CheckMed
  1389.         Case #Music
  1390.           If ModOn=1
  1391.              ModOn=0
  1392.              StopMed
  1393.              music=0
  1394.              Free MedModule 0
  1395.              DetachGTList 0
  1396.              GTDisable 0,#ModReq
  1397.              GTDisable 0,#ModString
  1398.              AttachGTList 0,1
  1399.           Else
  1400.              ModOn=1
  1401.              ld$=pa$+"/"+fi$
  1402.              LoadMedModule 0,ld$
  1403.              music=1
  1404.              Gosub MusicOn
  1405.              DetachGTList 0
  1406.              GTEnable 0,#ModReq
  1407.              GTEnable 0,#ModString
  1408.              AttachGTList 0,1
  1409.           EndIf
  1410.  
  1411.  
  1412.         Case #SndFilter
  1413.           If Fltr=True
  1414.              Fltr=False
  1415.           Else
  1416.              Fltr=True
  1417.           EndIf
  1418.           Gosub setflt
  1419.         Case #BtnUse
  1420.           split=1
  1421.           compname$=GTGetStr{0,62}
  1422.           playername$=GTGetStr{0,61}
  1423.       End Select
  1424.     EndIf
  1425.   EndIf
  1426.   FlushEvents
  1427. If split=0 Then Goto prefloop
  1428. split=0
  1429. VWait
  1430. Use Window 0
  1431. fadeto{3,1}
  1432. Free Window 1
  1433. Free GTList 0
  1434. Goto Playgame
  1435.  
  1436. .makenoise
  1437. SetMedMask 3
  1438. hold=Timeout(noise)
  1439. Sound noise,12
  1440. Return
  1441.  
  1442. .fademusic
  1443. For i=64 To 0 Step -1
  1444.   SetMedVolume i
  1445.   VWait 2
  1446. Next
  1447. StopMed
  1448. SetMedVolume 64
  1449. Return
  1450.  
  1451. .MusicOn
  1452.   If ModOn=1 Then StartMedModule 0
  1453. .setflt
  1454.   If Fltr=False
  1455.     Filter On
  1456.   Else
  1457.     Filter Off
  1458.   EndIf
  1459. Return
  1460.  
  1461. .CompComplain           ;complain in print and sound
  1462.     complain=complain + 1         ;and set a new complaint so we
  1463.     If complain>9 Then complain=1 ;don't say the same thing all the time
  1464.     Gosub makenoise
  1465. Return
  1466.  
  1467. .CompNoise
  1468.   Select complain             ;select a noise
  1469.        Case 1
  1470.         noise=25
  1471.        Case 2
  1472.         noise=30
  1473.        Case 3
  1474.         noise=24
  1475.        Case 4
  1476.         noise=29
  1477.        Case 5
  1478.         noise=16
  1479.        Case 6
  1480.         noise=31
  1481.        Case 7
  1482.         noise=1
  1483.        Case 8
  1484.         noise=7
  1485.        Case 9
  1486.         noise=32
  1487.     End Select
  1488. Return
  1489. .CheckMed
  1490. If newmod$<>""
  1491.   If ReadFile(0,newmod$)
  1492.     FileInput 0
  1493.     A$ = Edit$(12)    ; Read 12 bytes or upto a chr$(10)
  1494.     CloseFile 0
  1495.     If Left$(A$,3)= "MMD" AND Right$(A$,1) = "4"  ; OK, 4 channel MED
  1496.       size.l=FileSize(newmod$)                    ;check mod length
  1497.       If music=1 Then Gosub fademusic
  1498.       Free MedModule 0                          ;can old mod
  1499.       VWait 10
  1500.       chips.l=ChipFree                          ;check chip mem
  1501.       If chips>size+5000                             ;ok to load new mod
  1502.         ld$=newmod$                             ;so change name
  1503.         defpa$=pa$
  1504.         deffi$=fi$
  1505.         If GadgetHit = #ModReq Then GTSetString 0,#ModString,ld$
  1506.       Else                                      ;short on chip mem!
  1507.         A$=txt$(68)+" = "+Str$(chips)
  1508.         B$=txt$(69)+" "+Str$(size+5000)+"|"+txt$(70)
  1509.         Request A$,B$,txt$(61)
  1510.         pa$=defpa$
  1511.         fi$=deffi$
  1512.       EndIf
  1513.     ld$=pa$+"/"+fi$
  1514.     VWait 10
  1515.     LoadMedModule 0,ld$
  1516.     music=1
  1517.     Gosub MusicOn
  1518.     Else    ; not a 4 channel med!
  1519.       Request txt$(65),txt$(67),txt$(61)
  1520.     EndIf
  1521.   Else      ; can't even find it!
  1522.     Request txt$(65),txt$(66),txt$(64)
  1523.   EndIf
  1524. EndIf
  1525. Return
  1526. .savepref
  1527.   If WriteFile (0,"data/8prefs")         ;open pref file
  1528.     FileOutput 0
  1529.     NPrint compname$                     ;computer's name
  1530.     NPrint playername$                   ;player's name
  1531.     NPrint Fltr                          ;audio filter on or off
  1532.     NPrint pa$                           ;default path
  1533.     NPrint fi$                           ;mod name
  1534.     NPrint scbtn                         ;mx scorebutton selected
  1535.     NPrint maxpoints                     ;default top score
  1536.     NPrint scoreon                       ;add points to looser if 0
  1537.     NPrint pl                            ;save the palette
  1538.     NPrint ModOn                         ;use music if 1
  1539.     CloseFile 0
  1540.     WindowOutput 1
  1541.   Else
  1542.     Request txt$(60),txt$(71),txt$(64)
  1543.   EndIf
  1544. Return
  1545.  
  1546. .loadpref
  1547.   If ReadFile (0,"data/8prefs")          ;open pref file
  1548.     FileInput 0
  1549.     compname$=Edit$(15)                  ;computer's name
  1550.     playername$=Edit$(15)                ;player's name
  1551.     Fltr.b=Edit(6)                         ;audio filter on or off
  1552.     pa$=Edit$(200)                       ;default path
  1553.     fi$=Edit$(200)
  1554.     scbtn.b=Edit(6)                        ;mx scorebutton selected
  1555.     maxpoints.w=Edit(6)                    ;default top score
  1556.     scoreon.b=Edit(6)                      ;add points to looser if 0
  1557.     pl.b=Edit(6)                           ;get the palette
  1558.     ModOn.b=Edit(6)                        ;use music if 1
  1559.     CloseFile 0
  1560.     WindowInput 0
  1561.   Else                                   ;Use Defaults
  1562.     compname$="Amiga"                    ;computer's name
  1563.     playername$=txt$(57)                 ;player's name
  1564.     Fltr.b=False                         ;audio filter on or off
  1565.     pa$="data/Mods"                      ;default path
  1566.     fi$="Med.Moonshine"                  ;default module name
  1567.     scbtn.b=3                            ;mx scorebutton selected
  1568.     maxpoints.w=200                      ;default top score
  1569.     scoreon.b=0                          ;add points to looser if 0
  1570.     ModOn.b=1
  1571.     pl.b=1
  1572.   EndIf
  1573.   defpa$=pa$
  1574.   deffi$=fi$
  1575. Return
  1576.  
  1577. .GetLocale
  1578.   If ReadFile (0,"locale/C8.LOCALE")
  1579.     FileInput 0
  1580.     t$=Edit$(180)
  1581.     If Left$(t$,2)<>"C8" Then Goto badlocale
  1582.     i=0
  1583.     getAnother
  1584.     t$=Edit$(100)
  1585.       txt$(i)=t$
  1586.       i+1
  1587.     If i < 75
  1588.       If NOT Eof(0)
  1589.         Goto getAnother
  1590.       Else
  1591.         Goto badlocale
  1592.       EndIf
  1593.     Else
  1594.       CloseFile 0
  1595.       WindowInput 0
  1596.     EndIf
  1597.     Return
  1598.   EndIf
  1599.  
  1600. badlocale
  1601.   Request "Locale Error","Can't load Locale file|Please read the docs","Darn!"
  1602.   End
  1603.  
  1604. .PrintRequestor              ;this prints Continue & Exit on quit requestor
  1605.  ShapesBitMap 64,3           ;dummy bitmap so we can draw on a shape
  1606.  FNSOutput 3,1                 ;send the print to it
  1607.  
  1608.  FNSPrint 1,31,25,txt$(73),#centred,1 ;Continue
  1609.  FNSPrint 1,31,24,txt$(73),#centred,1
  1610.  FNSPrint 1,30,25,txt$(73),#centred,1
  1611.  FNSPrint 1,30,24,txt$(73),#centred,7
  1612.  
  1613.  
  1614.  FNSPrint 1,265,25,txt$(59),#centred,1 ;Quit
  1615.  FNSPrint 1,265,24,txt$(59),#centred,1
  1616.  FNSPrint 1,264,25,txt$(59),#centred,1
  1617.  FNSPrint 1,264,24,txt$(59),#centred,7
  1618.  
  1619.  ShapesBitMap 53,3           ;now the pref-menu-play requestor
  1620.  FNSOutput 3,1               ;send the print to it
  1621.  
  1622.  FNSPrint 1,24,27,txt$(74),#centred,1 ;Prefs
  1623.  FNSPrint 1,24,26,txt$(74),#centred,1
  1624.  FNSPrint 1,23,27,txt$(74),#centred,1
  1625.  FNSPrint 1,23,26,txt$(74),#centred,7
  1626.  
  1627.  FNSPrint 1,123,27,txt$(72),#centred,1 ;Menu
  1628.  FNSPrint 1,123,26,txt$(72),#centred,1
  1629.  FNSPrint 1,122,27,txt$(72),#centred,1
  1630.  FNSPrint 1,122,26,txt$(72),#centred,7
  1631.  
  1632.  
  1633.  
  1634.  FNSPrint 1,224,27,txt$(58),#centred,1 ;Play
  1635.  FNSPrint 1,224,26,txt$(58),#centred,1
  1636.  FNSPrint 1,223,27,txt$(58),#centred,1
  1637.  FNSPrint 1,223,26,txt$(58),#centred,7
  1638.  
  1639.  
  1640.  Return
  1641.  
  1642. .FixMode
  1643.   If ntsSys=True  ;original screen mode
  1644.     ForceNTSC
  1645.   Else
  1646.     ForcePAL
  1647.   EndIf
  1648. Return
  1649.  
  1650.  
  1651.  
  1652. INCDIR ""
  1653. Even
  1654.  
  1655. ;Incbin our font into the compiled file to save effort later
  1656. font_dat: IncBin "WINDY.FNS"
  1657.  
  1658.